<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1">
    <title>后台管理系统 - By梵天</title>
    <link rel="icon" type="image/png" href="__PUBLIC__/images/favicon.png?v=26838d09a1?v=26838d09a1">
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css">
    <link rel="stylesheet" href="__PUBLIC__/js/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/css/admin.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/dt.css"/>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 0px;">
    <legend>工时表单</legend>
</fieldset>
<div style="padding: 20px">
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui_inline">
                {present name="record"}
                <input type="text" class="layui-hide" name="recordid" value="{$record.id}">
                {/present}
                <label class="layui-form-label">站点</label>
                <div class="layui-input-inline">
                    <select lay-verify="required" id="stationsel" name="station" lay-filter="station">
                        <option selected value=""></option>
                        {volist name="stationlist" id="item"}
                            {present name="record"}
                                {eq name="record.station_id" value="$item.id"}
                                    <option selected value={$item.id}>{$item.name}</option>
                                    {else/}
                                     <option value={$item.id}>{$item.name}</option>
                                {/eq}
                            {else/}
                            <option value={$item.id}>{$item.name}</option>
                            {/present}
                        {/volist}
                        <!--变量嵌套这样用-->
                    </select>
                </div>
            </div>
            <div class="layui_inline" style="padding-left: 40px">
                <label class="layui-form-label">工作时间</label>
                <div class="layui-inline">
                    <div class="layui-input-line">
                        <input type="text" style="width: 200px" placeholder="开始时间" lay-verify="required" name="dates"
                               id="dates"  value="2017-7-24 " autocomplete="off" class="layui-input"
                               onclick="layui.laydate({elem: this,format: 'YYYY-MM-DD hh:mm'})">
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-line">
                        <input type="text" style="width: 200px" placeholder="结束时间" lay-verify="required" name="datee"
                               id="datee" autocomplete="off" class="layui-input"
                               onclick="layui.laydate({elem: this,format: 'YYYY-MM-DD hh:mm'})">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
        </div>

        <div class="layui-form-item">

            <label class="layui-form-label">工作人员</label>
            <div class="layui-input-block">
                {volist name="memberlist" id="item"}
                {present name="record"}

                    <div class="layui-inline">


                    <div class="layui-inline">
                        <input type="checkbox"
                               {volist name="gsvalue2" id="vo" key="k" }
                               {eq name="item.id" value="$vo.member_id" }
                                checked
                               {/eq}
                               {/volist}
                               id="members_{$item.id}" data-fuckid="{$item.id}" lay-filter="check"
                               name="members[{$item.id}]" title="{$item.name}">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="gsvalue[{$item.id}]" id="gsvalue_{$item.id}" placeholder="请输入"
                               autocomplete="off"
                               {volist name="gsvalue2" id="vo" key="k" }

                               {eq name="item.id" value="$vo.member_id" }

                                value="{$vo.gsvalue}"


                               {/eq}
                                {/volist}
                                class="layui-input ">


                    </div>




                     </div>
                {else/}

                <div class="layui-inline">
                    <div class="layui-inline">
                        <input type="checkbox"

                               id="members_{$item.id}" data-fuckid="{$item.id}" lay-filter="check"
                               name="members[{$item.id}]" title="{$item.name}">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="gsvalue[{$item.id}]" id="gsvalue_{$item.id}" placeholder="请输入"
                               autocomplete="off"
                               class="layui-input layui-disabled">
                    </div>
                </div>


                 {/present}
                {/volist}
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">工作内容</label>
            <div class="layui-input-block">
                <textarea  id="textareaid" name="content"  placeholder="请输入内容" class="layui-textarea">{present name="record"}{$record.content}{/present}
                </textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="demo2">跳转式提交</button>
        </div>
    </form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/plugins/layui/lay/dest/layui.all.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/jquery/1.9.1/jquery.min.js"></script>
<!--<script type="text/javascript" src="__PUBLIC__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>-->
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/myjs.js"></script>
<script>
    function defaultlaytime() {
        var laydate = layui.laydate;

        var start = {
            elem: '#dates'
            , format: 'YYYY-MM-DD hh:mm', //日期格式
            max: '2099-06-16 23:59:59'
            , istoday: true
            , istime: true
            , festival: true //是否显示节日
            , choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };

        var end = {
            elem: '#datee'
            , format: 'YYYY-MM-DD hh:mm' //日期格式

            , max: '2099-06-16 23:59:59'
            , istoday: false
            , istime: true
            , festival: true //是否显示节日
            , choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
//        laydate(start);
//        laydate(end);
        document.getElementById('dates').onclick = function () {
            start.elem = this;
            laydate(start);
        };
        document.getElementById('datee').onclick = function () {
            end.elem = this;
            laydate(end);
        };

        var mydate = new Date();
        {present name="record"}
        $('#dates').val("{$record.starttime}");
        $('#datee').val("{$record.donetime}");
        {else/}
        $('#dates').val(createstandardtime(mydate));
        mydate.setHours(mydate.getHours() + 1);
        $('#datee').val(createstandardtime(mydate));

        {/present}



    }

    function checkstation() {
        var stationid = "{$record.station.id|default='-1'}";
        $('.layui-form-select dl dd').each(function () {
            if ($(this).attr('lay-value') == stationid) {
                $(this).addClass('layui-this');
            }


        });
        layer.msg(stationid);

    }
</script>
<script>
    var index = null;
    $(function () {
        index = parent.layer.getFrameIndex(window.name); //获取窗口索
        var form = layui.form();
        var layedit = layui.layedit;
        var editindex= layedit.build('textareaid',
            {height:100, tool:['strong','italic','underline']
            }); //建立编辑器

//监听选择框
        form.on('checkbox(check)', function (data) {
            if (data.elem.checked) {
                $('#gsvalue_' + data.elem.dataset.fuckid).attr('lay-verify', 'required|fuckver');

            } else {
                $('#gsvalue_' + data.elem.dataset.fuckid).attr('lay-verify', '');

            }
        });


        //监听提交
        form.on('submit(demo2)', function (data) {

            var ischeck = $('.layui-form-checked');//判断有没有选择人员
            if (!ischeck.length) {
                layer.msg('请选择人员');
                return false;
            }

            if (!layedit.getText(editindex).length) {
                layer.msg('请输入工作内容！');
                return false;
            }
            data.field.content=layedit.getContent(editindex);

            $.post("{:Url('index/gsrecord/postaddgs')}", data.field, function (result) {
                    layer.msg(result.msg, {anim: 1, time: 1500}, function (index2) {
                        if (result.code) {
                            parent.refreshTable();
                            parent.layer.close(index);
                        }


                    });

                }
            );
            return false;
        });
    });

    defaultlaytime();

//    checkstation();
</script>
</body>
</html>